package com.zjsru.oneDay;

import java.util.ArrayList;
import java.util.List;

/**
 * 2942. 查找包含给定字符的单词
 *
 * @Author: cookLee
 * @Date: 2025-05-24
 */
public class FindWordsContaining {

    /**
     * 主
     * \
     * 输入：words = ["leet","code"], x = "e"
     * 输出：[0,1]
     * 解释："e" 在两个单词中都出现了："leet" 和 "code" 。所以我们返回下标 0 和 1 。
     * \
     *
     * @param args args
     */
    public static void main(String[] args) {
        FindWordsContaining findWordsContaining = new FindWordsContaining();
        System.out.println(findWordsContaining.findWordsContaining(new String[]{"leetcode", "et", "code"}, 'e'));
    }

    public List<Integer> findWordsContaining(String[] words, char x) {
        List<Integer> ans = new ArrayList<>();
        for (int i = 0; i < words.length; i++) {
            if (words[i].contains(String.valueOf(x))) {
                ans.add(i);
            }
        }
        return ans;
    }

}
